package aws.handler;

import java.net.MalformedURLException;
import java.net.URL;

import javax.xml.rpc.ServiceException;

import org.apache.axis.EngineConfiguration;
import org.apache.axis.configuration.FileProvider;

import aws.*;

public abstract class AbstractRequestHandler {

	protected static final String WSDD = "hmac.wsdd";

	protected static final String AWS_ACCESS_KEY_ID = "AKIAJWE76T5KEYRNGZRQ";

	protected static final String AWS_ASSOCIATE_TAG = "hkmangon-20";
	protected static URL PORT_ADDRESS;
	
	protected AWSECommerceServicePortType service;

	private int totalPages = 0;
	private int totalResults = 0;
	
	static {
		try {
			PORT_ADDRESS = new URL("https://soap.amazon.com/onca/soap?Service=AWSECommerceService");
		} catch (MalformedURLException e) {
			e.printStackTrace();
		}
	}
	
	public AbstractRequestHandler() {
        try {
        	EngineConfiguration serviceConfig = new FileProvider(WSDD);
        	AWSECommerceService locator = new AWSECommerceServiceLocator(serviceConfig);
			service = locator.getAWSECommerceServicePort(PORT_ADDRESS);
		} catch (ServiceException e) {
			e.printStackTrace();
		}

	}

	public AWSECommerceServicePortType getWebService() {
		return service;
	}

	public void setWebService(AWSECommerceServicePortType service) {
		this.service = service;
	}
	

	public int getTotalPages() {
		return totalPages;
	}

	public void setTotalPages(int totalPages) {
		this.totalPages = totalPages;
	}

	public int getTotalResults() {
		return totalResults;
	}

	public void setTotalResults(int totalResults) {
		this.totalResults = totalResults;
	}
	
}
